function dP0dvk = grad_dP0dv2(dudv,H,impossible,s,u)

Lambda = exp(-exp(-u(1:end-1)));
Lambda(impossible(1:end-1)) = 1;
F = 1 - exp(-s*u(end));
f = s*exp(-s*u(end));

summand = repmat(exp(-u(1:end-1)),[1,H-1]).*dudv(1:end-1,:)*F;
summand(repmat(impossible(1:end-1),[1,H-1])) = 0;

dP0dvk = prod(Lambda)*(sum(summand) + f*dudv(end,:));